import request from "@/utils/request";

/**
 * 校验密码
 * @param password
 * @returns {Promise | Promise<unknown>}
 */
export function checkPassword(password){
  return request({
    url : '/business/checkPassword',
    method: 'post',
    data : {
      password
    }
  })
}

/**
 * 校验是否验证了密码
 * @returns {Promise | Promise<unknown>}
 */
export function checkValidPassword(){
  return request({
    url : '/business/checkValidPassword',
    method: 'get',
    handleError: true,
  })
}

/**
 * 校验是否验证了手机号
 * @returns {Promise | Promise<unknown>}
 */
export function checkValidMobile(){
  return request({
    url : '/business/checkValidMobile',
    method: 'get',
    handleError: true,
  })
}


/**
 * 校验是否验证了邮箱
 * @returns {Promise | Promise<unknown>}
 */
export function checkValidEmail(){
  return request({
    url : '/business/checkValidEmail',
    method: 'get',
    handleError: true,
  })
}

/**
 * 更新密码
 * @param params
 * @returns {Promise<unknown>}
 */
export function updatePassword(params){
  return request({
    url : '/business/updatePassword',
    method: 'post',
    data : params,
  })
}

export function checkMobile(params){
  return request({
    url : '/business/checkMobile',
    method: 'post',
    data : params,
    handleError: true,
  })
}

/**
 * 校验邮箱是否正确
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function checkEmail(params){
  return request({
    url : '/business/checkEmail',
    method: 'post',
    data : params,
    handleError: true,
  })
}

/**
 * 获取商家的充值记录
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getRechargeLog(params = {}){
  return request({
    url: '/business/getRechargeLog',
    method: 'get',
    params
  })
}


/**
 * 获取商家的授权店铺
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getAccountList(params = {}){
  return request({
    url: '/business/getAccountList',
    method: 'get',
    params
  })
}

export function editAccount(params = {}){
  return request({
    url: `/business/editAccount/${params.accountId}`,
    method: 'patch',
    params,
    handleError: true,
  })
}

/**
 * 获取店铺的采集进度
 * @param accountId
 * @returns {Promise | Promise<unknown>}
 */
export function getAccountPercentage(accountId){
  return request({
    url: `/business/getAccountPercentage/${accountId}`,
    method: 'get',
  })
}

/**
 * 获取店铺接口
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getAllAccountList(params = {}){
  return request({
    url: '/business/getAllAccountList',
    method: 'get',
    params
  })

}
